package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.domain.db.Settings;
import com.tanhua.dubbo.mapper.SettingsMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class SettingsApiImpl implements SettingsApi{

    @Autowired
    private SettingsMapper settingsMapper;
    @Override
    public Settings findSettings(Long userId) {
        return settingsMapper.selectOne(new LambdaQueryWrapper<Settings>().eq(Settings::getUserId, userId));
    }

    @Override
    public void addSetting(Settings nowSettings) {
        settingsMapper.insert(nowSettings);
    }

    @Override
    public void updateSetting(Settings nowSettings) {
        settingsMapper.updateById(nowSettings);
    }
}
